import ply.yacc as yacc
from mmrsql_lex import tokens
from mmrsql_yacc import *
import pre_processor
from query_tree.builder import QueryTreeBuilder

test_sql = '''
select Asset_100000.MetaData:vendor, Asset_100000.MetaData:id
from Asset_100000 join Event on Asset.MetaData:id = Event.MetaData:id
where Asset.MetaData:vendor = 'hp' and Asset.MetaData:type = 'server' or Asset.MetaData:type = 'printer'
'''

test_sql = '''
select Asset_100000.MetaData:vendor
from Asset_100000
where Asset_10000.MetaData:type = 'server'
'''
parser = yacc.yacc()
parse_result_dict = parser.parse(test_sql)
print pre_processor.process(parse_result_dict)
builder = QueryTreeBuilder()
builder.build_query_tree(parse_result_dict)
